<template>
  <div class="change-class body-bg">
    <div v-if="!initLoading">
      <ul class="change-content" v-if="list.length">
        <li class="sign-items" v-for="(item,index) in list" :key="index" @click="goDet(item.season_id,item.class_hour_minute,item.goods_id)">
          <div class="items-top">
            <div class="teacher-infor">
              <img :src="item.student_avatar || '/static/images/user.png'" alt="头像">
              <span>{{item.student_name}}</span>
            </div>
          </div>
          <div class="item-cont">
            <p class="class-name overflow-one">{{item.goods_name}}</p>
            <p class="class-infor"><img src="/static/images/singUp/singUp-icon1.png" alt="icon">上课校区：{{item.campus_name}}</p>
            <p class="class-infor"><img src="/static/images/singUp/singUp-icon2.png" alt="icon">结课日期：{{item.end_date}}</p>
            <p class="class-infor"><img src="/static/images/singUp/singUp-icon3.png" alt="icon">班级课次：{{item.finish_lesson}}/{{item.lesson_total}}</p>
            <p class="class-infor"><img src="/static/images/singUp/singUp-icon3.png" alt="icon">教练：{{item.teacher_name}}</p>
            <!-- <img v-if="item.isTaoCan == '1'" class="taocan" src="/static/images/singUp/singUp-icon4.png" alt="套餐"> -->
          </div>
          <div class="items-tips">
            <span class="items-tip-biaoqie">续班</span>
          </div>
        </li>
        <!-- <li v-if="isReachBottom" class="pull-loading"><van-loading type="spinner" size="20px" color="#1989fa" /></li>
        <li v-if="isBottom" class="bottom-line">-- 亲，已经到最后了--</li> -->
      </ul>
      <div v-else class="empty">
        <img src="/static/images/empty-icon.png" alt="空">
        <p class="empty-tips">暂时还没有可续费班级哦</p>
      </div>
    </div>
    <div v-else class="init-loading"><van-loading type="spinner" color="#1989fa" /></div>
  </div>
</template>

<script>
import store from '../../store/globalStore'
export default {
  data() {
    return {
      initLoading: true, // 初始加载
      isBottom: false, // 是否加载完全部数据
      isReachBottom: false, // 是否显示加载状态
      curr_page: 1,
      page_size: 10,
      total: "",
      list: []
    }
  },
  onLoad() {
    this.getRenewList();
  },
  onShow() {
    // this.curr_page = 1;
    // this.isBottom = false;
    // this.getRenewList();
  },
  // // 下拉刷新
  // onPullDownRefresh: function() {
  //   this.curr_page = 1;
  //   this.isReachBottom = false;
  //   this.isBottom = false;
  //   this.getRenewList();
  // },
  // // 上拉加载
  // onReachBottom () {
  //   if(this.isBottom) return;
  //   this.isReachBottom = true;
  //   this.getRenewList();
  // },
  methods: {
    // 获取列表
    getRenewList() {
      wx.showNavigationBarLoading() //在标题栏中显示加载
      // if(this.isReachBottom) {
      //   this.curr_page++;
      // }
      this.$fetch.getRenewList()
      .then(res=>{
        wx.hideNavigationBarLoading() //在标题栏中隐藏加载
        wx.stopPullDownRefresh(); //完成停止加载
        this.initLoading = false;
        // this.total = res.result.total;
        // let len = 0;
        // if(this.isReachBottom) { // 判断是下拉还是上拉动作
        //   this.list = [...this.list, ...res.result.data];
        //   len = this.list.length;
        //   if(len >= this.total){
        //     this.isBottom = true;
        //   }
        //   this.isReachBottom = false;
        //   return
        // }
        this.list = res.result.data;
        // len = this.list.length;
        // if(len >= this.total){
        //   this.isBottom = true;
        // }
      }).catch(err=>{
        this.initLoading = false;
        // this.isReachBottom = false;
        wx.hideNavigationBarLoading() //在标题栏中隐藏加载
        wx.stopPullDownRefresh(); //完成停止加载
      })
    },
    // 去续费
    goDet(season_id,class_hour_minute,goods_id) {
      wx.navigateTo({
        url: `/pages/signUp/main?from=2&season_id=${season_id}&class_hour_minute=${class_hour_minute}&renew_goods_id=${goods_id}`
      })
    }
  },
}
</script>

<style lang="less" scope>
.change-class{
  width: 100%;
  min-height: 100vh;
  .change-content{
    width: 100%;
    padding-top: 14px;
    .sign-items{
      width: 100%;
      background: #fff;
      overflow: hidden;
      margin-bottom: 14px;
      .items-top{
        width: 100%;
        padding: 8px 20px;
        box-sizing: border-box;
        display: flex;
        justify-content: space-between;
        align-items: center;
        .teacher-infor{
          display: flex;
          justify-content: flex-start;
          align-items: center;
          img{
            width: 44px;
            height: 44px;
            display: block;
            border-radius: 50%;
          }
          span{
            margin-left: 10px;
            font-size: 14px;
            font-weight: bold;
            color: #000;
          }
        }
        .price{
          text-decoration:line-through;
          color: #A9A9A9;
          font-size: 14px;
          font-weight: bold;
        }
        .discount-price{
          color: #EE0000;
          font-size: 14px;
          font-weight: bold;
        }
      }
      .item-cont{
        width: 100%;
        background: #E5F9FF;
        padding: 14px 22px;
        box-sizing: border-box;
        position: relative;
        .taocan{
          position: absolute;
          top: 6px;
          right: 12px;
          width: 24px;
          height: 24px;
          display: block;
        }
        .class-name{
          width: 100%;
          font-size: 14px;
          color: #666;
          font-weight: bold;
        }
        .class-infor{
          width: 100%;
          font-size: 12px;
          color: #999;
          display: flex;
          justify-content: flex-start;
          align-items: center;
          margin-top: 10px;
          img{
            width: 12px;
            height: 12px;
            display: block;
            margin-right: 6px;
          }
        }
      }
      .items-tips{
        width: 100%;
        padding: 10px 12px;
        box-sizing: border-box;
        display: flex;
        flex-direction: row-reverse;
        align-items: center;
        .items-tip-biaoqie{
          padding: 4px 16px;
          border: 1px solid rgba(0,183,238,1);
          border-radius: 8px;
          font-size: 14px;
          color: #fff;
          background: #00B7EE;
          margin-left: 12px;
        }
      }
    }
  }
}
</style>
